<template>
	<div class="main-router-view">
		<div class="title">发布公告</div>
		<el-form label-width="100px" @submit.native.prevent="save">
			<el-form-item label="公告标题">
				<el-input v-model="model.title"></el-input>
			</el-form-item>
			<el-form-item label="公告内容">
				<el-input v-model="model.content" type="textarea" :rows="2"></el-input>
			</el-form-item>
			<el-form-item>
				<el-button type="primary" round native-type="submit">发布</el-button>
			</el-form-item>
		</el-form>
	</div>
</template>

<script>
	export default {
		name: "MessagePost",
		props: {},
		data() {
			return {
				model: {},
			};
		},
		methods: {


			// 提交发布
			async save() {

				if (!this.model.title || !this.model.content) {
					this.$message({
						type: "warning",
						message: "请输入公告标题/内容"
					});
					return;
				}


				let res = await this.http.post("admin/notices/create", this.model);
				this.$router.push({
					path: "/message/notice"
				});
				this.$message({
					type: "success",
					message: "发布成功"
				});
			},
		},
		created() {}
	};
</script>

<style>
	.title {
		font-weight: bold;
		font-size: 20px;
		margin-bottom: 20px;
	}

	.avatar-uploader .el-upload {
		border: 1px dashed #d9d9d9;
		border-radius: 6px;
		cursor: pointer;
		overflow: hidden;
	}

	.avatar-uploader .el-upload:hover {
		border-color: #409eff;
	}

	.avatar-uploader-icon {
		font-size: 28px;
		color: #8c939d;
		width: 178px;
		height: 178px;
		line-height: 178px;
		text-align: center;
	}

	.avatar {
		width: 178px;
		height: 178px;
		display: block;
	}
</style>
